#pragma once

#include <string>
#include <QFile>

using namespace std;

class CSelfFormartFile
{
public:
    CSelfFormartFile(const char* filename, string id, bool bCreate = false);
	~CSelfFormartFile();
public:
	void CloseFile();
	string GetID();
    bool BFileValid();
public:
	int ReadFile(void* readContent, int contentLen);
	int ReadLine(void* readcontent, int contentLen);
    bool ReadOver();

	int RWriteFile(void* writeStr, int nWriteSize);
	int AppendWriteFile(void* writeStr, int nWriteSize);
public:
    void SetEncrypt(bool bEncrypt);
public:
	void SetFileName(const char* filename);
	void GetFileName(char* outfilename, int nBuffersize);
public:
	int GetFileSize();
private:
    void manualOpen(bool bCreate);
private:
    QFile m_file;
    bool m_bEncrypt;
	string m_strID;

    bool m_bReadOver;
};

typedef CSelfFormartFile SELFFORMARTFILE, *PSELFFORMARTFILE;
